
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>03-Main Process API · 千锋大前端小册-Electron</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="古艺散人">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-insert-logo/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    

        
    
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="04-Renderer Process API.html" />
    
    
    <link rel="prev" href="02-搭建Electron运行环境.html" />
    

    
        <link rel="shortcut icon" href='../source/images/favicon.jpg' type="image/x-icon">
    
    
        <link rel="bookmark" href='../source/images/favicon.jpg' type="image/x-icon">
    
    
        <link rel="apple-touch-icon" href='../source/images/apple-touch-icon.jpg'>
    
    
        
        <link rel="apple-touch-icon" sizes="120x120" href="../source/images/apple-touch-icon.jpg">
        
        <link rel="apple-touch-icon" sizes="180x180" href="../source/images/apple-touch-icon.jpg">
        
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"lurongtao","repo":"felixbooks-electron","type":"star","size":"small","count":true}]};
    </script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="01-Electron介绍.html">
            
                <a href="01-Electron介绍.html">
            
                    
                    基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="01-Electron介绍.html">
            
                <a href="01-Electron介绍.html">
            
                    
                    01-Electron介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="02-搭建Electron运行环境.html">
            
                <a href="02-搭建Electron运行环境.html">
            
                    
                    02-搭建Electron运行环境
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2.3" data-path="03-Main Process API.html">
            
                <a href="03-Main Process API.html">
            
                    
                    03-Main Process API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="04-Renderer Process API.html">
            
                <a href="04-Renderer Process API.html">
            
                    
                    04-Renderer Process API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="05-IPC通信.html">
            
                <a href="05-IPC通信.html">
            
                    
                    05-IPC通信
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="06-Shared API.html">
            
                <a href="06-Shared API.html">
            
                    
                    06-Shared API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="07-特性和技巧.html">
            
                <a href="07-特性和技巧.html">
            
                    
                    07-特性和技巧
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../project/">
            
                <a href="../project/">
            
                    
                    项目实战
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../project/01-环境搭建.html">
            
                <a href="../project/01-环境搭建.html">
            
                    
                    01-环境搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../project/02-构建项目基本结构.html">
            
                <a href="../project/02-构建项目基本结构.html">
            
                    
                    02-构建项目基本结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../project/03-添加信息.html">
            
                <a href="../project/03-添加信息.html">
            
                    
                    03-添加信息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../project/04-获得屏幕快照.html">
            
                <a href="../project/04-获得屏幕快照.html">
            
                    
                    04-获得屏幕快照
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../project/05-显示列表.html">
            
                <a href="../project/05-显示列表.html">
            
                    
                    05-显示列表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../project/06-打开网站窗口.html">
            
                <a href="../project/06-打开网站窗口.html">
            
                    
                    06-打开网站窗口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../project/07-删除信息.html">
            
                <a href="../project/07-删除信息.html">
            
                    
                    07-删除信息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../project/08-搜索信息.html">
            
                <a href="../project/08-搜索信息.html">
            
                    
                    08-搜索信息
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="../project/09-定制菜单.html">
            
                <a href="../project/09-定制菜单.html">
            
                    
                    09-定制菜单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" data-path="../project/10-项目打包部署.html">
            
                <a href="../project/10-项目打包部署.html">
            
                    
                    10-项目打包部署
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../thanks/">
            
                <a href="../thanks/">
            
                    
                    感谢
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >03-Main Process API</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#main-process-api"><b></b>Main Process API</a></li><ul><li><span class="title-icon "></span><a href="#app"><b></b>App</a></li><ul><li><span class="title-icon "></span><a href="#&#x4E8B;&#x4EF6;"><b></b>&#x4E8B;&#x4EF6;</a></li><li><span class="title-icon "></span><a href="#&#x65B9;&#x6CD5;"><b></b>&#x65B9;&#x6CD5;</a></li></ul><li><span class="title-icon "></span><a href="#browserwindow"><b></b>BrowserWindow</a></li><ul><li><span class="title-icon "></span><a href="#&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;"><b></b>&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;</a></li><li><span class="title-icon "></span><a href="#&#x4F18;&#x96C5;&#x7684;&#x663E;&#x793A;&#x7A97;&#x53E3;"><b></b>&#x4F18;&#x96C5;&#x7684;&#x663E;&#x793A;&#x7A97;&#x53E3;</a></li><li><span class="title-icon "></span><a href="#&#x7236;&#x5B50;&#x7A97;&#x53E3;"><b></b>&#x7236;&#x5B50;&#x7A97;&#x53E3;</a></li><li><span class="title-icon "></span><a href="#&#x65E0;&#x8FB9;&#x6846;&#x7A97;&#x53E3;"><b></b>&#x65E0;&#x8FB9;&#x6846;&#x7A97;&#x53E3;</a></li><li><span class="title-icon "></span><a href="#&#x5C5E;&#x6027;&#x4E0E;&#x65B9;&#x6CD5;"><b></b>&#x5C5E;&#x6027;&#x4E0E;&#x65B9;&#x6CD5;</a></li><li><span class="title-icon "></span><a href="#state"><b></b>state</a></li><li><span class="title-icon "></span><a href="#webcontents"><b></b>webContents</a></li></ul><li><span class="title-icon "></span><a href="#session"><b></b>Session</a></li><ul><li><span class="title-icon "></span><a href="#&#x8D77;&#x6B65;"><b></b>&#x8D77;&#x6B65;</a></li><li><span class="title-icon "></span><a href="#cookie"><b></b>cookie</a></li><li><span class="title-icon "></span><a href="#downloaditem"><b></b>downloadItem</a></li></ul><li><span class="title-icon "></span><a href="#dialog---&#x5BF9;&#x8BDD;&#x6846;"><b></b>dialog - &#x5BF9;&#x8BDD;&#x6846;</a></li><li><span class="title-icon "></span><a href="#&#x5FEB;&#x6377;&#x952E;&#x7CFB;&#x7EDF;&#x5FEB;&#x6377;&#x952E;"><b></b>&#x5FEB;&#x6377;&#x952E;+&#x7CFB;&#x7EDF;&#x5FEB;&#x6377;&#x952E;</a></li><li><span class="title-icon "></span><a href="#menu"><b></b>Menu</a></li><li><span class="title-icon "></span><a href="#context-menus"><b></b>Context Menus</a></li><li><span class="title-icon "></span><a href="#tray-&#x6258;&#x76D8;"><b></b>Tray (&#x6258;&#x76D8;)</a></li><li><span class="title-icon "></span><a href="#powermonitor-&#x7535;&#x6E90;&#x6307;&#x793A;&#x5668;"><b></b>powerMonitor (&#x7535;&#x6E90;&#x6307;&#x793A;&#x5668;)</a></li></ul></ul></div><a href="#main-process-api" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="main-process-api"><a name="main-process-api" class="anchor-navigation-ex-anchor" href="#main-process-api"><i class="fa fa-link" aria-hidden="true"></i></a><a name="main-process-api" class="plugin-anchor" href="#main-process-api"><i class="fa fa-link" aria-hidden="true"></i></a>Main Process API</h1>
<blockquote>
<p>Electron API &#xFF08;Electron API &#x6709;&#x4E09;&#x79CD;&#xFF09;</p>
<ul>
<li>Main Process &#xFF08;&#x4E3B;&#x8FDB;&#x8FDB;&#x7A0B;&#xFF09;</li>
<li>Renderer Process&#xFF08;&#x6E32;&#x67D3;&#x8FDB;&#x7A0B;&#xFF09;</li>
<li>Share Modules&#xFF08;&#x5171;&#x4EAB;&#x6A21;&#x5757;&#xFF09;</li>
</ul>
</blockquote>
<h2 id="app"><a name="app" class="anchor-navigation-ex-anchor" href="#app"><i class="fa fa-link" aria-hidden="true"></i></a><a name="app" class="plugin-anchor" href="#app"><i class="fa fa-link" aria-hidden="true"></i></a>App</h2>
<h3 id="&#x4E8B;&#x4EF6;"><a name="&#x4E8B;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#&#x4E8B;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4E8B;&#x4EF6;" class="plugin-anchor" href="#&#x4E8B;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E8B;&#x4EF6;</h3>
<h4 id="ready"><a name="ready" class="anchor-navigation-ex-anchor" href="#ready"><i class="fa fa-link" aria-hidden="true"></i></a><a name="ready" class="plugin-anchor" href="#ready"><i class="fa fa-link" aria-hidden="true"></i></a>ready:</h4>
<blockquote>
<p>&#x5F53; Electron &#x5B8C;&#x6210;&#x521D;&#x59CB;&#x5316;&#x65F6;&#x88AB;&#x89E6;&#x53D1;&#x3002;</p>
</blockquote>
<ul>
<li>&#x4E24;&#x79CD;&#x4F7F;&#x7528;&#x65B9;&#x6CD5;</li>
</ul>
<pre><code>app.on(&apos;ready&apos;, createWindow)
app.on(&apos;ready&apos;, () =&gt; {
  console.log(&apos;App is ready!&apos;)
  createWindow()
})
</code></pre><ul>
<li><p>&#x68C0;&#x67E5;&#x5E94;&#x7528;&#x662F;&#x5426;&#x767B;&#x5F55;&#xFF1A;app.isReady()</p>
</li>
<li><p>&#x5982;&#x679C;&#x5E94;&#x7528;&#x6CA1;&#x6709;Ready&#xFF0C;app.isReady()&#x7684;&#x503C;&#x4E3A; false</p>
</li>
</ul>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x5E94;&#x7528;&#x662F;&#x5426;&#x767B;&#x5F55;&#xFF1A;&apos;</span> + app.isReady())
</code></pre>
<ul>
<li>&#x6B64;&#x65F6;&#x5E94;&#x7528;&#x5E94;&#x8BE5;&#x5DF2;&#x7ECF;Ready</li>
</ul>
<pre><code class="lang-js">setTimeout(() =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x5E94;&#x7528;&#x662F;&#x5426;&#x767B;&#x5F55;&#xFF1A;&apos;</span> + app.isReady())
}, <span class="hljs-number">2000</span>)
</code></pre>
<h4 id="before-quit"><a name="before-quit" class="anchor-navigation-ex-anchor" href="#before-quit"><i class="fa fa-link" aria-hidden="true"></i></a><a name="before-quit" class="plugin-anchor" href="#before-quit"><i class="fa fa-link" aria-hidden="true"></i></a>before-quit</h4>
<blockquote>
<p>&#x5728;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x5F00;&#x59CB;&#x5173;&#x95ED;&#x7A97;&#x53E3;&#x4E4B;&#x524D;&#x89E6;&#x53D1;&#x3002;</p>
</blockquote>
<pre><code class="lang-js">app.on(<span class="hljs-string">&apos;before-quit&apos;</span>, (e) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;App is quiting&apos;</span>)
  e.preventDefault()
})
</code></pre>
<h4 id="browser-window-blur"><a name="browser-window-blur" class="anchor-navigation-ex-anchor" href="#browser-window-blur"><i class="fa fa-link" aria-hidden="true"></i></a><a name="browser-window-blur" class="plugin-anchor" href="#browser-window-blur"><i class="fa fa-link" aria-hidden="true"></i></a>browser-window-blur</h4>
<blockquote>
<p>&#x5728; browserWindow &#x5931;&#x53BB;&#x7126;&#x70B9;&#x65F6;&#x53D1;&#x51FA;</p>
</blockquote>
<pre><code class="lang-js">app.on(<span class="hljs-string">&apos;browser-window-blur&apos;</span>, (e) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;App unfocused&apos;</span>)
})
</code></pre>
<h4 id="browser-window-focus"><a name="browser-window-focus" class="anchor-navigation-ex-anchor" href="#browser-window-focus"><i class="fa fa-link" aria-hidden="true"></i></a><a name="browser-window-focus" class="plugin-anchor" href="#browser-window-focus"><i class="fa fa-link" aria-hidden="true"></i></a>browser-window-focus</h4>
<blockquote>
<p>&#x5728; browserWindow &#x83B7;&#x5F97;&#x7126;&#x70B9;&#x65F6;&#x53D1;&#x51FA;</p>
</blockquote>
<pre><code class="lang-js">app.on(<span class="hljs-string">&apos;browser-window-focus&apos;</span>, (e) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;App focused&apos;</span>)
})
</code></pre>
<h3 id="&#x65B9;&#x6CD5;"><a name="&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x65B9;&#x6CD5;" class="plugin-anchor" href="#&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x65B9;&#x6CD5;</h3>
<h4 id="appquit"><a name="appquit" class="anchor-navigation-ex-anchor" href="#appquit"><i class="fa fa-link" aria-hidden="true"></i></a><a name="appquit" class="plugin-anchor" href="#appquit"><i class="fa fa-link" aria-hidden="true"></i></a>app.quit()</h4>
<pre><code class="lang-js">app.on(<span class="hljs-string">&apos;browser-window-blur&apos;</span>, (e) =&gt; {
  setTimeout(() =&gt; {
    app.quit()
  }, <span class="hljs-number">3000</span>)
})

app.on(<span class="hljs-string">&apos;browser-window-blur&apos;</span>, (e) =&gt; {
  setTimeout(app.quit, <span class="hljs-number">3000</span>)
})
</code></pre>
<h4 id="appgetpathname"><a name="appgetpathname" class="anchor-navigation-ex-anchor" href="#appgetpathname"><i class="fa fa-link" aria-hidden="true"></i></a><a name="appgetpathname" class="plugin-anchor" href="#appgetpathname"><i class="fa fa-link" aria-hidden="true"></i></a>app.getPath(name)</h4>
<pre><code class="lang-js">app.on(<span class="hljs-string">&apos;ready&apos;</span>, () =&gt; {
  <span class="hljs-built_in">console</span>.log(app.getPath(<span class="hljs-string">&apos;desktop&apos;</span>))
  <span class="hljs-built_in">console</span>.log(app.getPath(<span class="hljs-string">&apos;music&apos;</span>))
  <span class="hljs-built_in">console</span>.log(app.getPath(<span class="hljs-string">&apos;temp&apos;</span>))
  <span class="hljs-built_in">console</span>.log(app.getPath(<span class="hljs-string">&apos;userData&apos;</span>))

  createWindow()
})
</code></pre>
<h2 id="browserwindow"><a name="browserwindow" class="anchor-navigation-ex-anchor" href="#browserwindow"><i class="fa fa-link" aria-hidden="true"></i></a><a name="browserwindow" class="plugin-anchor" href="#browserwindow"><i class="fa fa-link" aria-hidden="true"></i></a>BrowserWindow</h2>
<blockquote>
<p>electron.BrowserWindow: &#x521B;&#x5EFA;&#x548C;&#x63A7;&#x5236;&#x6D4F;&#x89C8;&#x5668;&#x7A97;&#x53E3;</p>
</blockquote>
<h3 id="&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;"><a name="&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;" class="plugin-anchor" href="#&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;</h3>
<p>win.loadURL(url[, options]): &#x548C; loadFile &#x4E92;&#x65A5;</p>
<pre><code class="lang-js">mainWindow.loadURL(<span class="hljs-string">&apos;https://www.baidu.com&apos;</span>)
</code></pre>
<h3 id="&#x4F18;&#x96C5;&#x7684;&#x663E;&#x793A;&#x7A97;&#x53E3;"><a name="&#x4F18;&#x96C5;&#x7684;&#x663E;&#x793A;&#x7A97;&#x53E3;" class="anchor-navigation-ex-anchor" href="#&#x4F18;&#x96C5;&#x7684;&#x663E;&#x793A;&#x7A97;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x4F18;&#x96C5;&#x7684;&#x663E;&#x793A;&#x7A97;&#x53E3;" class="plugin-anchor" href="#&#x4F18;&#x96C5;&#x7684;&#x663E;&#x793A;&#x7A97;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4F18;&#x96C5;&#x7684;&#x663E;&#x793A;&#x7A97;&#x53E3;</h3>
<ul>
<li>&#x4F7F;&#x7528;ready-to-show&#x4E8B;&#x4EF6;</li>
</ul>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> mainWindow = <span class="hljs-keyword">new</span> BrowserWindow({ show: <span class="hljs-literal">false</span> })
mainWindow.once(<span class="hljs-string">&apos;ready-to-show&apos;</span>, () =&gt; {
  mainWindow.show()
})
</code></pre>
<ul>
<li>&#x8BBE;&#x7F6E; backgroundColor</li>
</ul>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> win = <span class="hljs-keyword">new</span> BrowserWindow({ backgroundColor: <span class="hljs-string">&apos;#2e2c29&apos;</span> })
</code></pre>
<h3 id="&#x7236;&#x5B50;&#x7A97;&#x53E3;"><a name="&#x7236;&#x5B50;&#x7A97;&#x53E3;" class="anchor-navigation-ex-anchor" href="#&#x7236;&#x5B50;&#x7A97;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x7236;&#x5B50;&#x7A97;&#x53E3;" class="plugin-anchor" href="#&#x7236;&#x5B50;&#x7A97;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7236;&#x5B50;&#x7A97;&#x53E3;</h3>
<ul>
<li>&#x7A97;&#x53E3;&#x5B9A;&#x4E49;</li>
</ul>
<pre><code class="lang-js">secondaryWindow = <span class="hljs-keyword">new</span> BrowserWindow({
  width: <span class="hljs-number">600</span>,
  height: <span class="hljs-number">600</span>,
  webPreferences: { nodeIntegration: <span class="hljs-literal">true</span> }
})

secondaryWindow.loadFile(<span class="hljs-string">&apos;index.html&apos;</span>)

secondaryWindow.on(<span class="hljs-string">&apos;closed&apos;</span>,  () =&gt; {
   mainWindow = <span class="hljs-literal">null</span>
})
</code></pre>
<ul>
<li>&#x7A97;&#x53E3;&#x5173;&#x7CFB;</li>
</ul>
<pre><code class="lang-js">secondaryWindow = <span class="hljs-keyword">new</span> BrowserWindow({
  parent: mainWindon, <span class="hljs-comment">// &#x5B9A;&#x4E49;&#x7236;&#x7A97;&#x53E3;</span>
  modal: <span class="hljs-literal">true</span> <span class="hljs-comment">// &#x9501;&#x5B9A;&#x5728;&#x4E3B;&#x7A97;&#x53E3;</span>
})
</code></pre>
<ul>
<li>&#x5B50;&#x7A97;&#x53E3;&#x663E;&#x793A;&#x548C;&#x9690;&#x85CF;</li>
</ul>
<pre><code class="lang-js">secondaryWindow = <span class="hljs-keyword">new</span> BrowserWindow({
  show: <span class="hljs-literal">false</span>
})

setTimeout(() =&gt; {
  secondaryWindow.show()
  setTimeout(() =&gt; {
    secondaryWindow.hide()
  }, <span class="hljs-number">3000</span>)
}, <span class="hljs-number">2000</span>)
</code></pre>
<h3 id="&#x65E0;&#x8FB9;&#x6846;&#x7A97;&#x53E3;"><a name="&#x65E0;&#x8FB9;&#x6846;&#x7A97;&#x53E3;" class="anchor-navigation-ex-anchor" href="#&#x65E0;&#x8FB9;&#x6846;&#x7A97;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x65E0;&#x8FB9;&#x6846;&#x7A97;&#x53E3;" class="plugin-anchor" href="#&#x65E0;&#x8FB9;&#x6846;&#x7A97;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x65E0;&#x8FB9;&#x6846;&#x7A97;&#x53E3;</h3>
<blockquote>
<p>Frameless Window</p>
</blockquote>
<pre><code class="lang-js">mainWindow = <span class="hljs-keyword">new</span> BrowserWindow({
  frame: <span class="hljs-literal">false</span>
})
</code></pre>
<p>&#x8BA9;&#x9875;&#x9762;&#x53EF;&#x62D6;&#x62FD;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">body</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&quot;user-select: none; -webkit-app-region:drag;&quot;</span>&gt;</span>
</code></pre>
<p>no-drag &#x4FEE;&#x590D;&#x4E0B;&#x9762;&#x63A7;&#x4EF6;&#x7684;bug</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&quot;-webkit-app-region: no-drag;&quot;</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;range&quot;</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;range&quot;</span> <span class="hljs-attr">min</span>=<span class="hljs-string">&quot;0&quot;</span> <span class="hljs-attr">max</span>=<span class="hljs-string">&quot;10&quot;</span>&gt;</span>
</code></pre>
<p>&#x663E;&#x793A;&#x7EA2;&#x7EFF;&#x706F;</p>
<pre><code class="lang-js">mainWindow = <span class="hljs-keyword">new</span> BrowserWindow({
  titleBarStyle: <span class="hljs-string">&apos;hidden&apos;</span> <span class="hljs-comment">// or hiddenInset &#x8DDD;&#x79BB;&#x7EA2;&#x7EFF;&#x706F;&#x66F4;&#x8FD1;</span>
})
</code></pre>
<h3 id="&#x5C5E;&#x6027;&#x4E0E;&#x65B9;&#x6CD5;"><a name="&#x5C5E;&#x6027;&#x4E0E;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x5C5E;&#x6027;&#x4E0E;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5C5E;&#x6027;&#x4E0E;&#x65B9;&#x6CD5;" class="plugin-anchor" href="#&#x5C5E;&#x6027;&#x4E0E;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5C5E;&#x6027;&#x4E0E;&#x65B9;&#x6CD5;</h3>
<h4 id="minwidth--minheight"><a name="minwidth--minheight" class="anchor-navigation-ex-anchor" href="#minwidth--minheight"><i class="fa fa-link" aria-hidden="true"></i></a><a name="minwidth--minheight" class="plugin-anchor" href="#minwidth--minheight"><i class="fa fa-link" aria-hidden="true"></i></a>minWidth &amp;&amp; minHeight</h4>
<pre><code class="lang-js">mainWindow = <span class="hljs-keyword">new</span> BrowserWindow({
  minWidth: <span class="hljs-number">300</span>,
  minHeight: <span class="hljs-number">300</span>
})
</code></pre>
<p>&#x66F4;&#x591A;&#x8BE6;&#x89C1;&#xFF1A;<a href="https://electronjs.org/docs/api/browser-window#new-browserwindowoptions" target="_blank">https://electronjs.org/docs/api/browser-window#new-browserwindowoptions</a></p>
<h4 id="&#x7A97;&#x53E3;&#x7126;&#x70B9;&#x4E8B;&#x4EF6;"><a name="&#x7A97;&#x53E3;&#x7126;&#x70B9;&#x4E8B;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#&#x7A97;&#x53E3;&#x7126;&#x70B9;&#x4E8B;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x7A97;&#x53E3;&#x7126;&#x70B9;&#x4E8B;&#x4EF6;" class="plugin-anchor" href="#&#x7A97;&#x53E3;&#x7126;&#x70B9;&#x4E8B;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x7A97;&#x53E3;&#x7126;&#x70B9;&#x4E8B;&#x4EF6;</h4>
<pre><code class="lang-js">secWindow = <span class="hljs-keyword">new</span> BrowserWindow({
  width: <span class="hljs-number">400</span>, height: <span class="hljs-number">300</span>,
  webPreferences: { nodeIntegration: <span class="hljs-literal">true</span> },
})

mainWindow.on(<span class="hljs-string">&apos;focus&apos;</span>, () =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;mainWindow focused&apos;</span>)
})

secWindow.on(<span class="hljs-string">&apos;focus&apos;</span>, () =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;secWindow focused&apos;</span>)
})

app.on(<span class="hljs-string">&apos;browser-window-focus&apos;</span>, () =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;App focused&apos;</span>)
})
</code></pre>
<h4 id="&#x9759;&#x6001;&#x65B9;&#x6CD5;"><a name="&#x9759;&#x6001;&#x65B9;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x9759;&#x6001;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x9759;&#x6001;&#x65B9;&#x6CD5;" class="plugin-anchor" href="#&#x9759;&#x6001;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x9759;&#x6001;&#x65B9;&#x6CD5;</h4>
<ul>
<li>getAllWindows()</li>
</ul>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> allWindows = BrowserWindow.getAllWindows()
<span class="hljs-built_in">console</span>.log(allWindows)
</code></pre>
<p>&#x66F4;&#x591A;&#x8BE6;&#x89C1;: <a href="https://electronjs.org/docs/api/browser-window#%E9%9D%99%E6%80%81%E6%96%B9%E6%B3%95" target="_blank">https://electronjs.org/docs/api/browser-window#%E9%9D%99%E6%80%81%E6%96%B9%E6%B3%95</a></p>
<h4 id="&#x5B9E;&#x4F8B;&#x5C5E;&#x6027;"><a name="&#x5B9E;&#x4F8B;&#x5C5E;&#x6027;" class="anchor-navigation-ex-anchor" href="#&#x5B9E;&#x4F8B;&#x5C5E;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5B9E;&#x4F8B;&#x5C5E;&#x6027;" class="plugin-anchor" href="#&#x5B9E;&#x4F8B;&#x5C5E;&#x6027;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B9E;&#x4F8B;&#x5C5E;&#x6027;</h4>
<ul>
<li>id</li>
</ul>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(secWindow.id)
</code></pre>
<p>&#x66F4;&#x591A;&#x8BE6;&#x89C1;&#xFF1A;<a href="https://electronjs.org/docs/api/browser-window#%E5%AE%9E%E4%BE%8B%E5%B1%9E%E6%80%A7" target="_blank">https://electronjs.org/docs/api/browser-window#%E5%AE%9E%E4%BE%8B%E5%B1%9E%E6%80%A7</a></p>
<h4 id="&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;_1"><a name="&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;_1" class="anchor-navigation-ex-anchor" href="#&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;_1"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;" class="plugin-anchor" href="#&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;</h4>
<ul>
<li>maximize()<pre><code>secWindow.on(&apos;closed&apos;, () =&gt; {
mainWindow.maximize()
})
</code></pre>&#x66F4;&#x591A;&#x8BE6;&#x89C1;&#xFF1A;<a href="https://electronjs.org/docs/api/browser-window#%E5%AE%9E%E4%BE%8B%E6%96%B9%E6%B3%95" target="_blank">https://electronjs.org/docs/api/browser-window#%E5%AE%9E%E4%BE%8B%E6%96%B9%E6%B3%95</a></li>
</ul>
<h3 id="state"><a name="state" class="anchor-navigation-ex-anchor" href="#state"><i class="fa fa-link" aria-hidden="true"></i></a><a name="state" class="plugin-anchor" href="#state"><i class="fa fa-link" aria-hidden="true"></i></a>state</h3>
<blockquote>
<p>electron-window-state &#x4FDD;&#x5B58;&#x7A97;&#x53E3;&#x7684;&#x72B6;&#x6001;
<code>npm install electron-window-state</code></p>
</blockquote>
<h3 id="webcontents"><a name="webcontents" class="anchor-navigation-ex-anchor" href="#webcontents"><i class="fa fa-link" aria-hidden="true"></i></a><a name="webcontents" class="plugin-anchor" href="#webcontents"><i class="fa fa-link" aria-hidden="true"></i></a>webContents</h3>
<blockquote>
<p>webContents &#x662F; EventEmitter &#x7684;&#x5B9E;&#x4F8B;&#xFF0C; &#x8D1F;&#x8D23;&#x6E32;&#x67D3;&#x548C;&#x63A7;&#x5236;&#x7F51;&#x9875;, &#x662F; BrowserWindow &#x5BF9;&#x8C61;&#x7684;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;&#x3002;</p>
<pre><code>let wc = mainWindow.webContents
console.log(wc)
</code></pre></blockquote>
<h4 id="&#x65B9;&#x6CD5;-getallwebcontents&#xFF09;"><a name="&#x65B9;&#x6CD5;-getallwebcontents&#xFF09;" class="anchor-navigation-ex-anchor" href="#&#x65B9;&#x6CD5;-getallwebcontents&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x65B9;&#x6CD5;-getallwebcontents&#xFF09;" class="plugin-anchor" href="#&#x65B9;&#x6CD5;-getallwebcontents&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x65B9;&#x6CD5; getAllWebContents(&#xFF09;</h4>
<ul>
<li>&#x8FD4;&#x56DE; WebContents[] - &#x6240;&#x6709; WebContents &#x5B9E;&#x4F8B;&#x7684;&#x6570;&#x7EC4;&#x3002; &#x5305;&#x542B;&#x6240;&#x6709;Windows&#xFF0C;webviews&#xFF0C;opened devtools &#x548C; devtools &#x6269;&#x5C55;&#x80CC;&#x666F;&#x9875;&#x7684; web &#x5185;&#x5BB9;<pre><code>const {app, BrowserWindow, webContents} = require(&apos;electron&apos;)
console.log(webContents.getAllWebContents())
</code></pre></li>
</ul>
<h4 id="&#x5B9E;&#x4F8B;&#x4E8B;&#x4EF6;"><a name="&#x5B9E;&#x4F8B;&#x4E8B;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#&#x5B9E;&#x4F8B;&#x4E8B;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5B9E;&#x4F8B;&#x4E8B;&#x4EF6;" class="plugin-anchor" href="#&#x5B9E;&#x4F8B;&#x4E8B;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B9E;&#x4F8B;&#x4E8B;&#x4EF6;</h4>
<ul>
<li>did-finish-load</li>
<li>dom-ready</li>
</ul>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;https://placekitten.com/500/500&quot;</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">&quot;&quot;</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
<span class="hljs-keyword">let</span> wc = mainWindow.webContents
wc.on(<span class="hljs-string">&apos;did-finish-load&apos;</span>, () =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;Conent fully loaded&apos;</span>)
})
wc.on(<span class="hljs-string">&apos;dom-ready&apos;</span>, () =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;DOM Ready&apos;</span>)
})
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<ul>
<li>new-window</li>
</ul>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">target</span>=<span class="hljs-string">&quot;_blank&quot;</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;https://placekitten.com/500/500&quot;</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">h3</span>&gt;</span>Kitten<span class="hljs-tag">&lt;/<span class="hljs-name">h3</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
wc.on(<span class="hljs-string">&apos;new-window&apos;</span>, (e, url) =&gt; {
  e.preventDefault()
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;DOM Ready&apos;</span>)
})
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<ul>
<li>before-input-event</li>
</ul>
<pre><code class="lang-js">wc.on(<span class="hljs-string">&apos;before-input-event&apos;</span>, (e, input) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${input.key}</span> : <span class="hljs-subst">${input.type}</span>`</span>)
})
</code></pre>
<ul>
<li>login</li>
<li>did-navigate</li>
</ul>
<pre><code class="lang-js">mainWindow.loadURL(<span class="hljs-string">&apos;https://httpbin.org/basic-auth/user/passwd&apos;</span>)

wc.on(<span class="hljs-string">&apos;login&apos;</span>, (e, request, authInfo, callback) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;Logging in:&apos;</span>)
  callback(<span class="hljs-string">&apos;user&apos;</span>, <span class="hljs-string">&apos;passwd&apos;</span>)
})

wc.on(<span class="hljs-string">&apos;did-navigate&apos;</span>, (e, url, statusCode, message) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Navigated to: <span class="hljs-subst">${url}</span>, with response code: <span class="hljs-subst">${statusCode}</span>`</span>)
  <span class="hljs-built_in">console</span>.log(message)
})
</code></pre>
<ul>
<li>media-started-playing</li>
<li>media-paused</li>
</ul>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">video</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;./mgm.mp4&quot;</span> <span class="hljs-attr">controls</span> <span class="hljs-attr">width</span>=<span class="hljs-string">&quot;400&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">video</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
wc.on(<span class="hljs-string">&apos;media-started-playing&apos;</span>, () =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;Video Started&apos;</span>)
})
wc.on(<span class="hljs-string">&apos;media-paused&apos;</span>, () =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;Video Paused&apos;</span>)
})
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<ul>
<li>context-menu : &#x53F3;&#x952E;&#x4E0A;&#x4E0B;&#x6587;&#x4FE1;&#x606F;</li>
</ul>
<pre><code class="lang-js">wc.on(<span class="hljs-string">&apos;context-menu&apos;</span>, (e, params) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Context menu opened on: <span class="hljs-subst">${params.mediaType}</span> at x:<span class="hljs-subst">${params.x}</span>, y:<span class="hljs-subst">${params.y}</span>`</span>)
})

wc.on(<span class="hljs-string">&apos;context-menu&apos;</span>, (e, params) =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`User seleted text: <span class="hljs-subst">${params.selectionText}</span>`</span>)
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Selection can be copied: <span class="hljs-subst">${params.editFlags.canCopy}</span>`</span>)
})
</code></pre>
<h4 id="&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;_2"><a name="&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;_2" class="anchor-navigation-ex-anchor" href="#&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;_2"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;" class="plugin-anchor" href="#&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;</h4>
<ul>
<li>executeJavaScript()</li>
</ul>
<pre><code class="lang-js">wc.on(<span class="hljs-string">&apos;context-menu&apos;</span>, (e, params) =&gt; {
  wc.executeJavaScript(<span class="hljs-string">`alert(&apos;<span class="hljs-subst">${params.selectionText}</span>&apos;)`</span>)
})
</code></pre>
<h2 id="session"><a name="session" class="anchor-navigation-ex-anchor" href="#session"><i class="fa fa-link" aria-hidden="true"></i></a><a name="session" class="plugin-anchor" href="#session"><i class="fa fa-link" aria-hidden="true"></i></a>Session</h2>
<blockquote>
<p>&#x7BA1;&#x7406;&#x6D4F;&#x89C8;&#x5668;&#x4F1A;&#x8BDD;&#x3001;cookie&#x3001;&#x7F13;&#x5B58;&#x3001;&#x4EE3;&#x7406;&#x8BBE;&#x7F6E;&#x7B49;&#x3002;</p>
</blockquote>
<h3 id="&#x8D77;&#x6B65;"><a name="&#x8D77;&#x6B65;" class="anchor-navigation-ex-anchor" href="#&#x8D77;&#x6B65;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x8D77;&#x6B65;" class="plugin-anchor" href="#&#x8D77;&#x6B65;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8D77;&#x6B65;</h3>
<ul>
<li>&#x521B;&#x5EFA;session&#x5BF9;&#x8C61;</li>
</ul>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> session = mainWindow.webContents.session
<span class="hljs-built_in">console</span>.log(session) <span class="hljs-comment">// {}</span>
</code></pre>
<ul>
<li>&#x5728;chromium &#x521B;&#x5EFA;localStorage&#xFF0C;&#x7136;&#x540E;&#x521B;&#x5EFA;&#x4E24;&#x4E2A;&#x7A97;&#x53E3;&#xFF0C;&#x4E24;&#x4E2A;session&#x5171;&#x4EAB;</li>
</ul>
<pre><code class="lang-js">mainWindow = <span class="hljs-keyword">new</span> BrowserWindow({
  width: <span class="hljs-number">1000</span>, height: <span class="hljs-number">800</span>,
  webPreferences: { nodeIntegration: <span class="hljs-literal">true</span> }
})

secWindow = <span class="hljs-keyword">new</span> BrowserWindow({
  width: <span class="hljs-number">500</span>, height: <span class="hljs-number">400</span>,
  webPreferences: { nodeIntegration: <span class="hljs-literal">true</span> }
})

<span class="hljs-keyword">let</span> session = mainWindow.webContents.session
<span class="hljs-keyword">let</span> session2 = mainWindow.webContents.session
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">Object</span>.is(session, session2)) <span class="hljs-comment">// true</span>

<span class="hljs-comment">// Load index.html into the new BrowserWindow</span>
mainWindow.loadFile(<span class="hljs-string">&apos;index.html&apos;</span>)
secWindow.loadFile(<span class="hljs-string">&apos;index.html&apos;</span>)

<span class="hljs-comment">// Open DevTools - Remove for PRODUCTION!</span>
mainWindow.webContents.openDevTools();
secWindow.webContents.openDevTools();

<span class="hljs-comment">// Listen for window being closed</span>
mainWindow.on(<span class="hljs-string">&apos;closed&apos;</span>,  () =&gt; {
  mainWindow = <span class="hljs-literal">null</span>
})
secWindow.on(<span class="hljs-string">&apos;closed&apos;</span>,  () =&gt; {
  secWindow = <span class="hljs-literal">null</span>
})
</code></pre>
<ul>
<li>defaultSession</li>
</ul>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> {app, BrowserWindow, session} = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;electron&apos;</span>)
<span class="hljs-keyword">let</span> ses = mainWindow.webContents.session
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">Object</span>.is(session.defaultSession, ses)) <span class="hljs-comment">// true</span>
</code></pre>
<ul>
<li>&#x81EA;&#x5B9A;&#x4E49;session</li>
</ul>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> customSes = session.fromPartition(<span class="hljs-string">&apos;part1&apos;</span>)
<span class="hljs-built_in">console</span>.log(<span class="hljs-built_in">Object</span>.is(customSes, ses)) <span class="hljs-comment">//false, &#x6B64;&#x65F6;customSes &#x8FD8;&#x662F;&#x5171;&#x4EAB;session</span>

secWindow = <span class="hljs-keyword">new</span> BrowserWindow({
  width: <span class="hljs-number">500</span>, height: <span class="hljs-number">400</span>,
  webPreferences: { 
    nodeIntegration: <span class="hljs-literal">true</span>,
    session: customSes <span class="hljs-comment">// &#x5B9A;&#x4E49;session, &#x6B64;&#x65F6;&#x5B50;&#x7A97;&#x53E3;&#x6709;&#x81EA;&#x5DF1;&#x7684;session</span>
  }
})

<span class="hljs-comment">// &#x5728;&#x5B50;&#x7A97;&#x53E3;&#x91CC;&#x521B;&#x5EFA;localstorge: winName/secWindow</span>
<span class="hljs-comment">// &#x5173;&#x95ED;&#x6240;&#x6709;&#x7A97;&#x53E3;&#xFF0C;&#x53D1;&#x73B0;&#x521B;&#x5EFA;&#x7684;localstorage&#x53C8;&#x6D88;&#x5931;&#x4E86;&#xFF0C;&#x56E0;&#x4E3A;&#x6B64;&#x65F6;&#x7684;session&#x5B58;&#x50A8;&#x5728;&#x5185;&#x5B58;&#x91CC;&#xFF0C;&#x91CD;&#x65B0;&#x542F;&#x52A8;&#x5E94;&#x7528;&#x53C8;&#x6D88;&#x5931;&#x4E86;&#x3002;&#x53EF;&#x4EE5;&#x52A0;&#x524D;&#x7F00;persist&#xFF0C;&#x4F7F;&#x5176;&#x53D8;&#x4E3A;&#x6C38;&#x4E45;&#x5B58;&#x50A8;&#xFF1A;</span>

<span class="hljs-keyword">let</span> customSes = session.fromPartition(<span class="hljs-string">&apos;persist:part1&apos;</span>)

<span class="hljs-comment">// &#x6216;&#x8005;&#xFF1A;</span>

secWindow = <span class="hljs-keyword">new</span> BrowserWindow({
  width: <span class="hljs-number">500</span>, height: <span class="hljs-number">400</span>,
  webPreferences: { 
    nodeIntegration: <span class="hljs-literal">true</span>,
    - session: customSes
    + partition: <span class="hljs-string">&apos;persist:part1&apos;</span>
  }
})
</code></pre>
<ul>
<li>&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;</li>
</ul>
<pre><code class="lang-js">ses.clearStorageData() <span class="hljs-comment">// &#x5220;&#x9664;&#x4E3B;&#x7A97;&#x53E3;&#x7684;&#x7684;storage</span>
</code></pre>
<h3 id="cookie"><a name="cookie" class="anchor-navigation-ex-anchor" href="#cookie"><i class="fa fa-link" aria-hidden="true"></i></a><a name="cookie" class="plugin-anchor" href="#cookie"><i class="fa fa-link" aria-hidden="true"></i></a>cookie</h3>
<blockquote>
<p>&#x67E5;&#x8BE2;&#x548C;&#x4FEE;&#x6539;&#x4E00;&#x4E2A;&#x4F1A;&#x8BDD;&#x7684;cookies</p>
</blockquote>
<pre><code class="lang-js"><span class="hljs-comment">// &#x67E5;&#x8BE2;&#x6240;&#x6709; cookies</span>
session.defaultSession.cookies.get({})
  .then((cookies) =&gt; {
    <span class="hljs-built_in">console</span>.log(cookies)
  }).catch((error) =&gt; {
    <span class="hljs-built_in">console</span>.log(error)
  })
</code></pre>
<pre><code class="lang-js"><span class="hljs-comment">// &#x67E5;&#x8BE2;&#x6240;&#x6709;&#x4E0E;&#x8BBE;&#x7F6E;&#x7684; URL &#x76F8;&#x5173;&#x7684;&#x6240;&#x6709; cookies</span>
session.defaultSession.cookies.get({ url: <span class="hljs-string">&apos;http://www.github.com&apos;</span> })
  .then((cookies) =&gt; {
    <span class="hljs-built_in">console</span>.log(cookies)
  }).catch((error) =&gt; {
    <span class="hljs-built_in">console</span>.log(error)
  })
</code></pre>
<pre><code class="lang-js"><span class="hljs-comment">// &#x8BBE;&#x7F6E;&#x4E00;&#x4E2A; cookie&#xFF0C;&#x4F7F;&#x7528;&#x8BBE;&#x7F6E;&#x7684;&#x540D;&#x79F0;&#xFF1B;</span>
<span class="hljs-comment">// &#x5982;&#x679C;&#x5B58;&#x5728;&#xFF0C;&#x5219;&#x4F1A;&#x8986;&#x76D6;&#x539F;&#x5148; cookie.</span>
<span class="hljs-keyword">const</span> cookie = { url: <span class="hljs-string">&apos;http://www.github.com&apos;</span>, name: <span class="hljs-string">&apos;dummy_name&apos;</span>, value: <span class="hljs-string">&apos;dummy&apos;</span> }
session.defaultSession.cookies.set(cookie)
  .then(() =&gt; {
    <span class="hljs-comment">// success</span>
  }, (error) =&gt; {
    <span class="hljs-built_in">console</span>.error(error)
  })
</code></pre>
<h3 id="downloaditem"><a name="downloaditem" class="anchor-navigation-ex-anchor" href="#downloaditem"><i class="fa fa-link" aria-hidden="true"></i></a><a name="downloaditem" class="plugin-anchor" href="#downloaditem"><i class="fa fa-link" aria-hidden="true"></i></a>downloadItem</h3>
<blockquote>
<p>&#x63A7;&#x5236;&#x6765;&#x81EA;&#x4E8E;&#x8FDC;&#x7A0B;&#x8D44;&#x6E90;&#x7684;&#x6587;&#x4EF6;&#x4E0B;&#x8F7D;&#x3002;</p>
</blockquote>
<pre><code class="lang-html">
<span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;https://picsum.photos/5000/5000/&quot;</span> <span class="hljs-attr">download</span>&gt;</span>Download Image<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">progress</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;0&quot;</span> <span class="hljs-attr">max</span>=<span class="hljs-string">&quot;100&quot;</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;progress&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">progress</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
  <span class="hljs-built_in">window</span>.progress = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">&apos;progress&apos;</span>)
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<pre><code class="lang-js"><span class="hljs-comment">// main.js</span>
<span class="hljs-keyword">let</span> ses = session.defaultSession

ses.on(<span class="hljs-string">&apos;will-download&apos;</span>, (e, downloadItem, webContents) =&gt; {

  <span class="hljs-keyword">let</span> fileName = downloadItem.getFilename()
  <span class="hljs-keyword">let</span> fileSize = downloadItem.getTotalBytes()

  <span class="hljs-comment">// Save to desktop</span>
  downloadItem.setSavePath(app.getPath(<span class="hljs-string">&apos;desktop&apos;</span>) + <span class="hljs-string">`/<span class="hljs-subst">${fileName}</span>`</span>)

  downloadItem.on(<span class="hljs-string">&apos;updated&apos;</span>, (e, state) =&gt; {

    <span class="hljs-keyword">let</span> received = downloadItem.getReceivedBytes()

    <span class="hljs-keyword">if</span> (state === <span class="hljs-string">&apos;progressing&apos;</span> &amp;&amp; received) {
      <span class="hljs-keyword">let</span> progress = <span class="hljs-built_in">Math</span>.round((received/fileSize)*<span class="hljs-number">100</span>)
      webContents.executeJavaScript(<span class="hljs-string">`window.progress.value = <span class="hljs-subst">${progress}</span>`</span>)
    }
  })
})
</code></pre>
<h2 id="dialog---&#x5BF9;&#x8BDD;&#x6846;"><a name="dialog---&#x5BF9;&#x8BDD;&#x6846;" class="anchor-navigation-ex-anchor" href="#dialog---&#x5BF9;&#x8BDD;&#x6846;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="dialog---&#x5BF9;&#x8BDD;&#x6846;" class="plugin-anchor" href="#dialog---&#x5BF9;&#x8BDD;&#x6846;"><i class="fa fa-link" aria-hidden="true"></i></a>dialog - &#x5BF9;&#x8BDD;&#x6846;</h2>
<blockquote>
<p>&#x663E;&#x793A;&#x7528;&#x4E8E;&#x6253;&#x5F00;&#x548C;&#x4FDD;&#x5B58;&#x6587;&#x4EF6;&#x3001;&#x8B66;&#x62A5;&#x7B49;&#x7684;&#x672C;&#x673A;&#x7CFB;&#x7EDF;&#x5BF9;&#x8BDD;&#x6846;</p>
</blockquote>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> {app, BrowserWindow, dialog} = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;electron&apos;</span>)

mainWindow.webContents.on(<span class="hljs-string">&apos;did-finish-load&apos;</span>, () =&gt; {
  dialog.showOpenDialog({
    buttonLabel: <span class="hljs-string">&apos;&#x9009;&#x62E9;&apos;</span>,
    defaultPath: app.getPath(<span class="hljs-string">&apos;desktop&apos;</span>),
    properties: [<span class="hljs-string">&apos;multiSelections&apos;</span>, <span class="hljs-string">&apos;createDirectory&apos;</span>, <span class="hljs-string">&apos;openFile&apos;</span>, <span class="hljs-string">&apos;openDirectory&apos;</span>]
  }, filepaths =&gt; {
    <span class="hljs-built_in">console</span>.log(filepaths)
  })
})
</code></pre>
<pre><code class="lang-js">dialog.showSaveDialog({}, filename =&gt; {
  <span class="hljs-built_in">console</span>.log(filename)
})
</code></pre>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> answers = [<span class="hljs-string">&apos;Yes&apos;</span>, <span class="hljs-string">&apos;No&apos;</span>, <span class="hljs-string">&apos;Maybe&apos;</span>]

dialog.showMessageBox({
  title: <span class="hljs-string">&apos;Message Box&apos;</span>,
  message: <span class="hljs-string">&apos;Please select an option&apos;</span>,
  detail: <span class="hljs-string">&apos;Message details.&apos;</span>,
  buttons: answers
}, response =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`User selected: <span class="hljs-subst">${answers[response]}</span>`</span>)
})
</code></pre>
<h2 id="&#x5FEB;&#x6377;&#x952E;&#x7CFB;&#x7EDF;&#x5FEB;&#x6377;&#x952E;"><a name="&#x5FEB;&#x6377;&#x952E;&#x7CFB;&#x7EDF;&#x5FEB;&#x6377;&#x952E;" class="anchor-navigation-ex-anchor" href="#&#x5FEB;&#x6377;&#x952E;&#x7CFB;&#x7EDF;&#x5FEB;&#x6377;&#x952E;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5FEB;&#x6377;&#x952E;&#x7CFB;&#x7EDF;&#x5FEB;&#x6377;&#x952E;" class="plugin-anchor" href="#&#x5FEB;&#x6377;&#x952E;&#x7CFB;&#x7EDF;&#x5FEB;&#x6377;&#x952E;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5FEB;&#x6377;&#x952E;+&#x7CFB;&#x7EDF;&#x5FEB;&#x6377;&#x952E;</h2>
<blockquote>
<p><strong>&#x5FEB;&#x6377;&#x952E;</strong>&#xFF1A;&#x5B9A;&#x4E49;&#x952E;&#x76D8;&#x5FEB;&#x6377;&#x952E;&#x3002;
<strong>&#x7CFB;&#x7EDF;&#x5FEB;&#x6377;&#x952E;</strong>&#xFF1A;&#x5728;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x6CA1;&#x6709;&#x952E;&#x76D8;&#x7126;&#x70B9;&#x65F6;&#xFF0C;&#x76D1;&#x542C;&#x952E;&#x76D8;&#x4E8B;&#x4EF6;&#x3002;</p>
</blockquote>
<p>&#x5FEB;&#x6377;&#x952E;&#x53EF;&#x4EE5;&#x5305;&#x542B;&#x591A;&#x4E2A;&#x529F;&#x80FD;&#x952E;&#x548C;&#x4E00;&#x4E2A;&#x952E;&#x7801;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x7531;&#x7B26;&#x53F7;+&#x7ED3;&#x5408;&#xFF0C;&#x7528;&#x6765;&#x5B9A;&#x4E49;&#x4F60;&#x5E94;&#x7528;&#x4E2D;&#x7684;&#x952E;&#x76D8;&#x5FEB;&#x6377;&#x952E;</p>
<p>&#x793A;&#x4F8B;&#xFF1A;</p>
<ul>
<li>CommandOrControl+A</li>
<li>CommandOrControl+Shift+Z</li>
</ul>
<p>&#x5FEB;&#x6377;&#x65B9;&#x5F0F;&#x4F7F;&#x7528; register &#x65B9;&#x6CD5;&#x5728; globalShortcut &#x6A21;&#x5757;&#x4E2D;&#x6CE8;&#x518C;&#x3002;</p>
<p>globalShortcut &#x6A21;&#x5757;&#x53EF;&#x4EE5;&#x5728;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x4E2D;&#x6CE8;&#x518C;/&#x6CE8;&#x9500;&#x5168;&#x5C40;&#x5FEB;&#x6377;&#x952E;, &#x4EE5;&#x4FBF;&#x53EF;&#x4EE5;&#x4E3A;&#x64CD;&#x4F5C;&#x5B9A;&#x5236;&#x5404;&#x79CD;&#x5FEB;&#x6377;&#x952E;&#x3002;</p>
<p>&#x6CE8;&#x610F;: &#x5FEB;&#x6377;&#x65B9;&#x5F0F;&#x662F;&#x5168;&#x5C40;&#x7684;; &#x5373;&#x4F7F;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x6CA1;&#x6709;&#x952E;&#x76D8;&#x7126;&#x70B9;, &#x5B83;&#x4E5F;&#x4ECD;&#x7136;&#x5728;&#x6301;&#x7EED;&#x76D1;&#x542C;&#x952E;&#x76D8;&#x4E8B;&#x4EF6;&#x3002; &#x5728;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x6A21;&#x5757;&#x53D1;&#x51FA; ready &#x4E8B;&#x4EF6;&#x4E4B;&#x524D;, &#x4E0D;&#x5E94;&#x4F7F;&#x7528;&#x6B64;&#x6A21;&#x5757;&#x3002;</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> {app, BrowserWindow, globalShortcut} = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;electron&apos;</span>)

globalShortcut.register(<span class="hljs-string">&apos;G&apos;</span>, () =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;User pressed G&apos;</span>)
})
</code></pre>
<pre><code class="lang-js">globalShortcut.register(<span class="hljs-string">&apos;CommandOrControl+Y&apos;</span>, () =&gt; {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;User pressed G with a combination key&apos;</span>)
  globalShortcut.unregister(<span class="hljs-string">&apos;CommandOrControl+G&apos;</span>)
})
</code></pre>
<h2 id="menu"><a name="menu" class="anchor-navigation-ex-anchor" href="#menu"><i class="fa fa-link" aria-hidden="true"></i></a><a name="menu" class="plugin-anchor" href="#menu"><i class="fa fa-link" aria-hidden="true"></i></a>Menu</h2>
<h5 id="1&#x3001;indexhtml"><a name="1&#x3001;indexhtml" class="anchor-navigation-ex-anchor" href="#1&#x3001;indexhtml"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1&#x3001;indexhtml" class="plugin-anchor" href="#1&#x3001;indexhtml"><i class="fa fa-link" aria-hidden="true"></i></a>1&#x3001;index.html</h5>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!DOCTYPE html&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">http-equiv</span>=<span class="hljs-string">&quot;Content-Security-Policy&quot;</span> <span class="hljs-attr">content</span>=<span class="hljs-string">&quot;script-src &apos;self&apos; &apos;unsafe-inline&apos;&quot;</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Hello World!<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Hello World!<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">textarea</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;name&quot;</span> <span class="hljs-attr">rows</span>=<span class="hljs-string">&quot;8&quot;</span> <span class="hljs-attr">cols</span>=<span class="hljs-string">&quot;80&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">textarea</span>&gt;</span>

    <span class="hljs-comment">&lt;!-- All of the Node.js APIs are available in this renderer process. --&gt;</span>
    We are using Node.js <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript"><span class="hljs-built_in">document</span>.write( process.versions.node)</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>,
    and Electron <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript"><span class="hljs-built_in">document</span>.write( process.versions.electron )</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>.

    <span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
      <span class="hljs-comment">// You can also require other files to run in this process</span>
      <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;./renderer.js&apos;</span>)
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<h5 id="2&#x3001;mainjs"><a name="2&#x3001;mainjs" class="anchor-navigation-ex-anchor" href="#2&#x3001;mainjs"><i class="fa fa-link" aria-hidden="true"></i></a><a name="2&#x3001;mainjs" class="plugin-anchor" href="#2&#x3001;mainjs"><i class="fa fa-link" aria-hidden="true"></i></a>2&#x3001;main.js</h5>
<pre><code class="lang-js"><span class="hljs-comment">// Modules</span>
<span class="hljs-keyword">const</span> {app, BrowserWindow, Menu, MenuItem} = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;electron&apos;</span>)

<span class="hljs-comment">// Keep a global reference of the window object, if you don&apos;t, the window will</span>
<span class="hljs-comment">// be closed automatically when the JavaScript object is garbage collected.</span>
<span class="hljs-keyword">let</span> mainWindow

<span class="hljs-keyword">let</span> mainMenu = Menu.buildFromTemplate( <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;./mainMenu&apos;</span>) )


<span class="hljs-comment">// Create a new BrowserWindow when `app` is ready</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createWindow</span> (<span class="hljs-params"></span>) </span>{

  mainWindow = <span class="hljs-keyword">new</span> BrowserWindow({
    width: <span class="hljs-number">1000</span>, height: <span class="hljs-number">800</span>,
    webPreferences: { nodeIntegration: <span class="hljs-literal">true</span> }
  })

  <span class="hljs-comment">// Load index.html into the new BrowserWindow</span>
  mainWindow.loadFile(<span class="hljs-string">&apos;index.html&apos;</span>)

  <span class="hljs-comment">// Open DevTools - Remove for PRODUCTION!</span>
  mainWindow.webContents.openDevTools();

  Menu.setApplicationMenu(mainMenu)

  <span class="hljs-comment">// Listen for window being closed</span>
  mainWindow.on(<span class="hljs-string">&apos;closed&apos;</span>,  () =&gt; {
    mainWindow = <span class="hljs-literal">null</span>
  })
}

<span class="hljs-comment">// Electron `app` is ready</span>
app.on(<span class="hljs-string">&apos;ready&apos;</span>, createWindow)

<span class="hljs-comment">// Quit when all windows are closed - (Not macOS - Darwin)</span>
app.on(<span class="hljs-string">&apos;window-all-closed&apos;</span>, () =&gt; {
  <span class="hljs-keyword">if</span> (process.platform !== <span class="hljs-string">&apos;darwin&apos;</span>) app.quit()
})

<span class="hljs-comment">// When app icon is clicked and app is running, (macOS) recreate the BrowserWindow</span>
app.on(<span class="hljs-string">&apos;activate&apos;</span>, () =&gt; {
  <span class="hljs-keyword">if</span> (mainWindow === <span class="hljs-literal">null</span>) createWindow()
})
</code></pre>
<h5 id="3&#x3001;mainmenujs"><a name="3&#x3001;mainmenujs" class="anchor-navigation-ex-anchor" href="#3&#x3001;mainmenujs"><i class="fa fa-link" aria-hidden="true"></i></a><a name="3&#x3001;mainmenujs" class="plugin-anchor" href="#3&#x3001;mainmenujs"><i class="fa fa-link" aria-hidden="true"></i></a>3&#x3001;mainMenu.js</h5>
<pre><code class="lang-js"><span class="hljs-built_in">module</span>.exports = [
  {
    label: <span class="hljs-string">&apos;Electron&apos;</span>,
    submenu: [
      { label: <span class="hljs-string">&apos;Item 1&apos;</span>},
      { label: <span class="hljs-string">&apos;Item 2&apos;</span>, submenu: [ { label: <span class="hljs-string">&apos;Sub Item 1&apos;</span>} ]},
      { label: <span class="hljs-string">&apos;Item 3&apos;</span>},
    ]
  },
  {
    label: <span class="hljs-string">&apos;Edit&apos;</span>,
    submenu: [
      { role: <span class="hljs-string">&apos;undo&apos;</span>},
      { role: <span class="hljs-string">&apos;redo&apos;</span>},
      { role: <span class="hljs-string">&apos;copy&apos;</span>},
      { role: <span class="hljs-string">&apos;paste&apos;</span>},
    ]
  },
  {
    label: <span class="hljs-string">&apos;Actions&apos;</span>,
    submenu: [
      {
        label: <span class="hljs-string">&apos;DevTools&apos;</span>,
        role: <span class="hljs-string">&apos;toggleDevTools&apos;</span>
      },
      {
        role: <span class="hljs-string">&apos;toggleFullScreen&apos;</span>
      },
      {
        label: <span class="hljs-string">&apos;Greet&apos;</span>,
        click: () =&gt; { <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;Hello from Main Menu&apos;</span>) },
        accelerator: <span class="hljs-string">&apos;Shift+Alt+G&apos;</span>
      }
    ]
  }
]
</code></pre>
<h2 id="context-menus"><a name="context-menus" class="anchor-navigation-ex-anchor" href="#context-menus"><i class="fa fa-link" aria-hidden="true"></i></a><a name="context-menus" class="plugin-anchor" href="#context-menus"><i class="fa fa-link" aria-hidden="true"></i></a>Context Menus</h2>
<h5 id="1&#x3001;indexhtml_1"><a name="1&#x3001;indexhtml_1" class="anchor-navigation-ex-anchor" href="#1&#x3001;indexhtml_1"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1&#x3001;indexhtml" class="plugin-anchor" href="#1&#x3001;indexhtml"><i class="fa fa-link" aria-hidden="true"></i></a>1&#x3001;index.html</h5>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!DOCTYPE html&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">http-equiv</span>=<span class="hljs-string">&quot;Content-Security-Policy&quot;</span> <span class="hljs-attr">content</span>=<span class="hljs-string">&quot;script-src &apos;self&apos; &apos;unsafe-inline&apos;&quot;</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Hello World!<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Hello World!<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">textarea</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;name&quot;</span> <span class="hljs-attr">rows</span>=<span class="hljs-string">&quot;8&quot;</span> <span class="hljs-attr">cols</span>=<span class="hljs-string">&quot;80&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">textarea</span>&gt;</span>

    <span class="hljs-comment">&lt;!-- All of the Node.js APIs are available in this renderer process. --&gt;</span>
    We are using Node.js <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript"><span class="hljs-built_in">document</span>.write( process.versions.node)</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>,
    and Electron <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript"><span class="hljs-built_in">document</span>.write( process.versions.electron )</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>.

    <span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
      <span class="hljs-comment">// You can also require other files to run in this process</span>
      <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;./renderer.js&apos;</span>)
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<h5 id="2&#x3001;mainjs_1"><a name="2&#x3001;mainjs_1" class="anchor-navigation-ex-anchor" href="#2&#x3001;mainjs_1"><i class="fa fa-link" aria-hidden="true"></i></a><a name="2&#x3001;mainjs" class="plugin-anchor" href="#2&#x3001;mainjs"><i class="fa fa-link" aria-hidden="true"></i></a>2&#x3001;main.js</h5>
<pre><code class="lang-js"><span class="hljs-comment">// Modules</span>
<span class="hljs-keyword">const</span> {app, BrowserWindow, Menu} = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;electron&apos;</span>)

<span class="hljs-comment">// Keep a global reference of the window object, if you don&apos;t, the window will</span>
<span class="hljs-comment">// be closed automatically when the JavaScript object is garbage collected.</span>
<span class="hljs-keyword">let</span> mainWindow

<span class="hljs-keyword">let</span> contextMenu = Menu.buildFromTemplate([
  { label: <span class="hljs-string">&apos;Item 1&apos;</span> },
  { role: <span class="hljs-string">&apos;editMenu&apos;</span> }
])

<span class="hljs-comment">// Create a new BrowserWindow when `app` is ready</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createWindow</span> (<span class="hljs-params"></span>) </span>{

  mainWindow = <span class="hljs-keyword">new</span> BrowserWindow({
    width: <span class="hljs-number">1000</span>, height: <span class="hljs-number">800</span>,
    webPreferences: { nodeIntegration: <span class="hljs-literal">true</span> }
  })

  <span class="hljs-comment">// Load index.html into the new BrowserWindow</span>
  mainWindow.loadFile(<span class="hljs-string">&apos;index.html&apos;</span>)

  <span class="hljs-comment">// Open DevTools - Remove for PRODUCTION!</span>
  mainWindow.webContents.openDevTools();

  mainWindow.webContents.on(<span class="hljs-string">&apos;context-menu&apos;</span>, e =&gt; {
    contextMenu.popup()
  })

  <span class="hljs-comment">// Listen for window being closed</span>
  mainWindow.on(<span class="hljs-string">&apos;closed&apos;</span>,  () =&gt; {
    mainWindow = <span class="hljs-literal">null</span>
  })
}

<span class="hljs-comment">// Electron `app` is ready</span>
app.on(<span class="hljs-string">&apos;ready&apos;</span>, createWindow)

<span class="hljs-comment">// Quit when all windows are closed - (Not macOS - Darwin)</span>
app.on(<span class="hljs-string">&apos;window-all-closed&apos;</span>, () =&gt; {
  <span class="hljs-keyword">if</span> (process.platform !== <span class="hljs-string">&apos;darwin&apos;</span>) app.quit()
})

<span class="hljs-comment">// When app icon is clicked and app is running, (macOS) recreate the BrowserWindow</span>
app.on(<span class="hljs-string">&apos;activate&apos;</span>, () =&gt; {
  <span class="hljs-keyword">if</span> (mainWindow === <span class="hljs-literal">null</span>) createWindow()
})
</code></pre>
<h2 id="tray-&#x6258;&#x76D8;"><a name="tray-&#x6258;&#x76D8;" class="anchor-navigation-ex-anchor" href="#tray-&#x6258;&#x76D8;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="tray-&#x6258;&#x76D8;" class="plugin-anchor" href="#tray-&#x6258;&#x76D8;"><i class="fa fa-link" aria-hidden="true"></i></a>Tray (&#x6258;&#x76D8;)</h2>
<h5 id="1&#x3001;mainjs"><a name="1&#x3001;mainjs" class="anchor-navigation-ex-anchor" href="#1&#x3001;mainjs"><i class="fa fa-link" aria-hidden="true"></i></a><a name="1&#x3001;mainjs" class="plugin-anchor" href="#1&#x3001;mainjs"><i class="fa fa-link" aria-hidden="true"></i></a>1&#x3001;main.js</h5>
<pre><code class="lang-js"><span class="hljs-comment">// Modules</span>
<span class="hljs-keyword">const</span> {app, BrowserWindow, Tray, Menu} = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;electron&apos;</span>)

<span class="hljs-comment">// Keep a global reference of the window object, if you don&apos;t, the window will</span>
<span class="hljs-comment">// be closed automatically when the JavaScript object is garbage collected.</span>
<span class="hljs-keyword">let</span> mainWindow, tray

<span class="hljs-keyword">let</span> trayMenu = Menu.buildFromTemplate([
  { label: <span class="hljs-string">&apos;Item 1&apos;</span> },
  { role: <span class="hljs-string">&apos;quit&apos;</span> }
])

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createTray</span>(<span class="hljs-params"></span>) </span>{

  tray = <span class="hljs-keyword">new</span> Tray(<span class="hljs-string">&apos;trayTemplate@2x.png&apos;</span>)
  tray.setToolTip(<span class="hljs-string">&apos;Tray details&apos;</span>)

  tray.on(<span class="hljs-string">&apos;click&apos;</span>, e =&gt; {

    <span class="hljs-keyword">if</span> (e.shiftKey) {
      app.quit()
    } <span class="hljs-keyword">else</span> {
      mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show()
    }
  })

  tray.setContextMenu(trayMenu)
}

<span class="hljs-comment">// Create a new BrowserWindow when `app` is ready</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createWindow</span> (<span class="hljs-params"></span>) </span>{

  createTray()

  mainWindow = <span class="hljs-keyword">new</span> BrowserWindow({
    width: <span class="hljs-number">1000</span>, height: <span class="hljs-number">800</span>,
    webPreferences: { nodeIntegration: <span class="hljs-literal">true</span> }
  })

  <span class="hljs-comment">// Load index.html into the new BrowserWindow</span>
  mainWindow.loadFile(<span class="hljs-string">&apos;index.html&apos;</span>)

  <span class="hljs-comment">// Open DevTools - Remove for PRODUCTION!</span>
  mainWindow.webContents.openDevTools();

  <span class="hljs-comment">// Listen for window being closed</span>
  mainWindow.on(<span class="hljs-string">&apos;closed&apos;</span>,  () =&gt; {
    mainWindow = <span class="hljs-literal">null</span>
  })
}

<span class="hljs-comment">// Electron `app` is ready</span>
app.on(<span class="hljs-string">&apos;ready&apos;</span>, createWindow)

<span class="hljs-comment">// Quit when all windows are closed - (Not macOS - Darwin)</span>
app.on(<span class="hljs-string">&apos;window-all-closed&apos;</span>, () =&gt; {
  <span class="hljs-keyword">if</span> (process.platform !== <span class="hljs-string">&apos;darwin&apos;</span>) app.quit()
})

<span class="hljs-comment">// When app icon is clicked and app is running, (macOS) recreate the BrowserWindow</span>
app.on(<span class="hljs-string">&apos;activate&apos;</span>, () =&gt; {
  <span class="hljs-keyword">if</span> (mainWindow === <span class="hljs-literal">null</span>) createWindow()
})
</code></pre>
<h2 id="powermonitor-&#x7535;&#x6E90;&#x6307;&#x793A;&#x5668;"><a name="powermonitor-&#x7535;&#x6E90;&#x6307;&#x793A;&#x5668;" class="anchor-navigation-ex-anchor" href="#powermonitor-&#x7535;&#x6E90;&#x6307;&#x793A;&#x5668;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="powermonitor-&#x7535;&#x6E90;&#x6307;&#x793A;&#x5668;" class="plugin-anchor" href="#powermonitor-&#x7535;&#x6E90;&#x6307;&#x793A;&#x5668;"><i class="fa fa-link" aria-hidden="true"></i></a>powerMonitor (&#x7535;&#x6E90;&#x6307;&#x793A;&#x5668;)</h2>
<pre><code class="lang-js"><span class="hljs-comment">// Modules</span>
<span class="hljs-keyword">const</span> electron = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;electron&apos;</span>)
<span class="hljs-keyword">const</span> {app, BrowserWindow} = electron

<span class="hljs-comment">// Keep a global reference of the window object, if you don&apos;t, the window will</span>
<span class="hljs-comment">// be closed automatically when the JavaScript object is garbage collected.</span>
<span class="hljs-keyword">let</span> mainWindow

<span class="hljs-comment">// Create a new BrowserWindow when `app` is ready</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createWindow</span> (<span class="hljs-params"></span>) </span>{

  mainWindow = <span class="hljs-keyword">new</span> BrowserWindow({
    width: <span class="hljs-number">1000</span>, height: <span class="hljs-number">800</span>,
    webPreferences: { nodeIntegration: <span class="hljs-literal">true</span> }
  })

  <span class="hljs-comment">// Load index.html into the new BrowserWindow</span>
  mainWindow.loadFile(<span class="hljs-string">&apos;index.html&apos;</span>)

  <span class="hljs-comment">// Open DevTools - Remove for PRODUCTION!</span>
  mainWindow.webContents.openDevTools();

  <span class="hljs-comment">// Listen for window being closed</span>
  mainWindow.on(<span class="hljs-string">&apos;closed&apos;</span>,  () =&gt; {
    mainWindow = <span class="hljs-literal">null</span>
  })

  electron.powerMonitor.on(<span class="hljs-string">&apos;resume&apos;</span>, e =&gt; {
    <span class="hljs-keyword">if</span>(!mainWindow) createWindow()
  })

  electron.powerMonitor.on(<span class="hljs-string">&apos;suspend&apos;</span>, e =&gt; {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;Saving some data&apos;</span>)
  })
}

<span class="hljs-comment">// Electron `app` is ready</span>
app.on(<span class="hljs-string">&apos;ready&apos;</span>, createWindow)

<span class="hljs-comment">// Quit when all windows are closed - (Not macOS - Darwin)</span>
app.on(<span class="hljs-string">&apos;window-all-closed&apos;</span>, () =&gt; {
  <span class="hljs-keyword">if</span> (process.platform !== <span class="hljs-string">&apos;darwin&apos;</span>) app.quit()
})

<span class="hljs-comment">// When app icon is clicked and app is running, (macOS) recreate the BrowserWindow</span>
app.on(<span class="hljs-string">&apos;activate&apos;</span>, () =&gt; {
  <span class="hljs-keyword">if</span> (mainWindow === <span class="hljs-literal">null</span>) createWindow()
})
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="02-搭建Electron运行环境.html" class="navigation navigation-prev " aria-label="Previous page: 02-搭建Electron运行环境">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="04-Renderer Process API.html" class="navigation navigation-next " aria-label="Next page: 04-Renderer Process API">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"03-Main Process API","level":"1.2.3","depth":2,"next":{"title":"04-Renderer Process API","level":"1.2.4","depth":2,"path":"basics/04-Renderer Process API.md","ref":"./basics/04-Renderer Process API.md","articles":[]},"previous":{"title":"02-搭建Electron运行环境","level":"1.2.2","depth":2,"path":"basics/02-搭建Electron运行环境.md","ref":"./basics/02-搭建Electron运行环境.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","splitter","expandable-chapters-small","anchors","github","github-buttons","sharing-plus","anchor-navigation-ex","favicon","insert-logo","livereload"],"styles":{"website":"./styles/website.css"},"pluginsConfig":{"github":{"url":"https://github.com/lurongtao/felixbooks-electron"},"livereload":{},"splitter":{},"search":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"favicon":{"shortcut":"./source/images/favicon.jpg","bookmark":"./source/images/favicon.jpg","appleTouch":"./source/images/apple-touch-icon.jpg","appleTouchMore":{"120x120":"./source/images/apple-touch-icon.jpg","180x180":"./source/images/apple-touch-icon.jpg"}},"github-buttons":{"buttons":[{"user":"lurongtao","repo":"felixbooks-electron","type":"star","size":"small","count":true}]},"expandable-chapters-small":{},"sharing":{"qq":false,"all":["google","facebook","weibo","twitter","qq","qzone","linkedin","pocket"],"douban":false,"facebook":false,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{},"insert-logo":{"url":"/felixbooks-electron/images/logo.png","style":"background: skyblue; width: 100%; height: 100%;"}},"theme":"default","author":"古艺散人","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"千锋大前端小册-Electron","language":"zh-hans","links":{},"gitbook":"3.2.3","description":"Electron 入门与实战"},"file":{"path":"basics/03-Main Process API.md","mtime":"2020-03-01T05:29:55.032Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-03-01T09:36:09.030Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-insert-logo/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

